﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetNuke.Common.Utilities;
using net.diadrasis.dnn.jsImageGallery.Data;

namespace net.diadrasis.dnn.jsImageGallery.Components
{
    public class cImageController
    {
        public static cImage GetImage(int imgId)
        {
           return CBO.FillObject<cImage>(DataProvider.Instance().GetImage(imgId));
        }

        public static List<cImage> GetImages(int modId)
        {
            return CBO.FillCollection<cImage>(DataProvider.Instance().GetImages(modId));
        }

        /**** get section images *******/
        public static List<cImage> GetSectionImages(int imgsecId)
        {
            return CBO.FillCollection<cImage>(DataProvider.Instance().GetSectionImages(imgsecId));
        }

        public static void DeleteImage(int imgId)
        {
            DataProvider.Instance().DeleteImage(imgId);
        }

        public static int SaveImage(cImage img, int tabID)
        {
            if (img.id < 1)
            {
                img.id = DataProvider.Instance().AddImage(img);
            }
            else
            {
                DataProvider.Instance().UpdateImage(img);
            }
            return img.id;
        }
    }
}